package logic;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

public class Constantes {
	
	public static ArrayList<String> Images;
	public final static String ImagesPatch = "Images.xml" ;
	

	public static final int CASILLAS_X 	= 20;
	public static final int CASILLAS_Y 	= 20;
	public static final int DEFAULT_LABEL_WIDTH = 50;
	public static final int DEFAULT_LABEL_HEIGHT = 50;
	public static final int DEFAULT_BOARD_WIDTH = 1000;
	public static final int DEFAULT_BOARD_HEIGHT = 1000;
	
	public static final int POS_X		= 0;
	public static final int POS_Y		= 1;
	
	// Types
	public static final int TYPE_PIPES_SPACE	= 0;
	public static final int TYPE_COMMAND		= 1;
	public static final int TYPE_VAR			= 2;
	
	// Ids pipes
	public static final int ID_VERT_UP	= 0;
	// Ids command
	public static final int ID_INICIO	= 0;
	public static final int ID_IF		= 1;
	public static final int ID_ENDIF	= 2;
	
	
	// posiciones alrededor del token
	public static final int CNT_POS	= 9;
	public static final int POS_NW	= 0;
	public static final int POS_N	= 1;
	public static final int POS_NE	= 2;
	public static final int POS_E	= 3;
	public static final int POS_SE	= 5;
	public static final int POS_S	= 6;
	public static final int POS_SW	= 7;
	public static final int POS_W	= 8;
	
	// opciones de adyacencia
	public static final int ADY_NONE		= 0;
	public static final int ADY_PIPE_IN		= 1;
	public static final int ADY_PIPE_OUT	= 2;
	public static final int ADY_PIPE		= 3; // usada para var
	public static final int ADY_VAR			= 4;
	public static final int ADY_ANY			= 5;
	
	// imagenes de bloques
	public static final String IMAGE_FOLDER = "GIFS/";
	public static final String IMAGE_ERROR 	= "block_error";
	public static final String IMAGE_STATIC = "_static";
	public static final String IMAGE_ANIM 	= "_anim";
	public static final String IMAGE_FORMAT = ".gif";
	
	// adyacencias
	// TODO: esto luego sera implementado por medio de un xml
	public static int ADY_OPTION[][][] = {
		{	// pipes
			// 0  = SN
			{ ADY_ANY, 		ADY_PIPE_IN, 	ADY_ANY, 	ADY_NONE, 		ADY_NONE, 	ADY_NONE, 		ADY_ANY, 	ADY_PIPE_OUT, 	ADY_ANY },
			// 1  = WS
			{ ADY_ANY, 		ADY_NONE, 		ADY_ANY, 	ADY_PIPE_IN, 	ADY_NONE, 	ADY_NONE, 		ADY_ANY, 	ADY_PIPE_OUT, 	ADY_ANY },
			// 2  = NE
			{ ADY_ANY, 		ADY_PIPE_OUT, 	ADY_ANY, 	ADY_NONE, 		ADY_NONE, 	ADY_PIPE_IN, 	ADY_ANY, 	ADY_NONE, 		ADY_ANY },
			// 3  = SE
			{ ADY_ANY, 		ADY_NONE, 		ADY_ANY, 	ADY_NONE, 		ADY_NONE, 	ADY_PIPE_IN, 	ADY_ANY, 	ADY_PIPE_OUT, 	ADY_ANY },
			// 4  = WN
			{ ADY_ANY, 		ADY_PIPE_OUT,	ADY_ANY, 	ADY_PIPE_IN,	ADY_NONE, 	ADY_NONE, 		ADY_ANY, 	ADY_NONE, 		ADY_ANY },
			// 5  = WE
			{ ADY_ANY, 		ADY_VAR, 		ADY_ANY, 	ADY_PIPE_OUT,	ADY_NONE, 	ADY_PIPE_IN,	ADY_ANY, 	ADY_VAR, 		ADY_ANY },
			// 6  = NS
			{ ADY_ANY, 		ADY_PIPE_OUT,	ADY_ANY, 	ADY_NONE, 		ADY_NONE, 	ADY_NONE, 		ADY_ANY, 	ADY_PIPE_IN,	ADY_ANY },
			// 7  = WS
			{ ADY_ANY, 		ADY_NONE, 		ADY_ANY, 	ADY_PIPE_OUT,	ADY_NONE, 	ADY_NONE, 		ADY_ANY, 	ADY_PIPE_IN,	ADY_ANY },
			// 8  = EN
			{ ADY_ANY, 		ADY_PIPE_IN,	ADY_ANY, 	ADY_NONE, 		ADY_NONE, 	ADY_PIPE_OUT,	ADY_ANY, 	ADY_NONE, 		ADY_ANY },
			// 9  = ES
			{ ADY_ANY, 		ADY_NONE, 		ADY_ANY, 	ADY_NONE, 		ADY_NONE, 	ADY_PIPE_OUT,	ADY_ANY, 	ADY_PIPE_IN,	ADY_ANY },
			// 10 = WN
			{ ADY_ANY, 		ADY_PIPE_IN,	ADY_ANY, 	ADY_PIPE_OUT,	ADY_NONE, 	ADY_NONE, 		ADY_ANY, 	ADY_NONE, 		ADY_ANY },
			// 11 = EW
			{ ADY_ANY, 		ADY_VAR,		ADY_ANY, 	ADY_PIPE_IN, 	ADY_NONE, 	ADY_PIPE_OUT,	ADY_ANY, 	ADY_VAR, 		ADY_ANY }
		},
		{	// commands
			// inicio
			{ ADY_NONE, 	ADY_NONE, 		ADY_NONE, 	ADY_NONE, 		ADY_NONE, 	ADY_PIPE_IN, 	ADY_NONE, 	ADY_PIPE_IN, 	ADY_NONE },
			{ ADY_ANY, 		ADY_ANY, 		ADY_ANY, 	ADY_ANY, 		ADY_ANY, 	ADY_ANY, 		ADY_ANY, 	ADY_ANY, 		ADY_ANY }
			
			
		},
		{	// vars
			{ ADY_ANY, 		ADY_PIPE, 		ADY_ANY, 	ADY_VAR, 		ADY_NONE, 	ADY_VAR, 		ADY_ANY, 	ADY_PIPE, 		ADY_ANY }
		}
	};
	
	public final static String IMAGES[] = {
		 "GIFS/01_static.gif" , "GIFS/02_static.gif" , "GIFS/03_static.gif" ,
		 "GIFS/10_static.gif" , "GIFS/12_static.gif" , "GIFS/13_static.gif" ,
		 "GIFS/20_static.gif" , "GIFS/21_static.gif" , "GIFS/23_static.gif" ,
		 "GIFS/30_static.gif" , "GIFS/31_static.gif" , "GIFS/32_static.gif" 
		};
}
